All Questions
86 questions
3votes
1answer
132views
Efficient least-significant digit (LSD) radix sort for int keys in Java
(This post has a continuation post.) This one is my attempt at LSD radix sort: Code com.github.coderodde.util.LSDRadixsort.java: ...
3votes
1answer
88views
Creating Worst-Case Scenario for QuickSort using Middle Pivot in Java
I've implemented a solution to generate the worst-case scenario for QuickSort using the middle pivot strategy in Java. The goal is to rearrange an input array to produce the worst performance during ...
3votes
2answers
216views
Counting duplicate elements in two sorted arrays
I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
1vote
1answer
118views
Queue-mergesort: a mergesort that does optimal number of comparisons in the worst case in Java
Here is the code for queue-mergesort by Mordecai J. Golin and Robert Sedgewick: com.github.coderodde.util.QueueMergesort.java: ...
2votes
1answer
357views
Sorting visualizer using Java Swing
I programmed a little sorting visualizer a while back and I have been meaning to get some feedback on the overall implementation and on what I could do better to have cleaner code or a "best ...
1vote
1answer
82views
Insertion Sorting Algorithm
I am new to data structures and algorithms. I have just implemented an insertion sorting algorithm. I just want to make sure if my code is alright. ...
1vote
1answer
255views
Find Kth Element in the merged two sorted arrays?
We have been given two sorted arrays and a number K . We have to merge the two sorted arrays in the sorted manner and return the element at the Kth position. My approach is to use two variables ...
5votes
1answer
82views
Selection Sort Java and Analysis
I have written a selection sort code in java. I know its very elementary algorithm, but since i am learning, so wanted your input about the quality of the code. Please have a look at the code: package ...
3votes
3answers
384views
Comparing binary insertion sort with straight insertion sort in Java
Straight insertion sort When inserting an element into its proper location to the left, one can achieve that by \$n\$ adjacent swaps which totals to \$3n\$ assignments. Straight insertion sort, ...
2votes
1answer
934views
Sorting algorithms in Kotlin - Bubble, Insertion, Selection, Merge and Quick sort
Introduction I decided to try Kotlin because of its forgiving nature to long-time Java users. I implemented a few introductory sorting algorithms and would like to have them reviewed, not just to ...
2votes
1answer
144views
Merge sort implementation with various improvements
So I was working on merge sort today, and was trying to speed it up. I would like your opinion on the implementation and if it's possible to make it faster. Besides that I was wondering if there are ...
5votes
2answers
3kviews
Hackerrank "Almost Equal" solution
I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
3votes
1answer
801views
Sorting an array of numbers in Java with an algorithm
This is pretty much one of my first programs that I have created in Java and I just wanted to ask if anyone sees some obvious errors or mistakes I made. The purpose of this program is to sort numbers ...
3votes
1answer
141views
Selection and Insertion sorts from scratch in Java
I am trying to find a good, basic way to make selection and insertion sorts so that I can manipulate them for other sorting techniques. How do these look? Is there a simpler way to write them? ...
3votes
2answers
177views
Evaluation of a variation of quick-sort (pivot-selection)
Here is a variation of quick-sort where-in the pivot selection is based on calculating the average of the values of the highest and lowest numbers. ...